﻿using System;

namespace Chengqbd.Core.Extensions
{
    /// <summary>
    /// 时间操作方法
    /// </summary>
	public static class DateTimeExtensions
	{
        /// <summary>
        /// 返回日期部分字符串
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
		public static string ToDateString(this DateTime time)
		{
			return time.ToString("yyyy-MM-dd");
		}
        /// <summary>
        /// 返回日期，时，分
        /// yyyy-MM-dd HH:mm
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
		public static string ToDateTimeString(this DateTime time)
		{
			return time.ToString("yyyy-MM-dd HH:mm");
		}
        /// <summary>
        /// yyyyMMddHHmm
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
		public static string ToDateMinutesString(this DateTime time)
		{
			return time.ToString("yyyyMMddHHmm");
		}
        /// <summary>
        /// yyyyMMddHHmmssfffffff
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
		public static string ToDateSecondsString(this DateTime dt)
		{
			return dt.ToString("yyyyMMddHHmmssfffffff");
		}
        /// <summary>
        /// 东八区转成utc
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
		public static DateTime ToUTCTime(this DateTime time)
		{
			return time.AddHours(-8.0);
		}
        
		public static DateTime ToBJTime(this DateTime utcTime)
		{
			return utcTime.AddHours(8.0);
		}
	}
}
